var lat='';
var lng='';
var geolocation = new BMap.Geolocation();
// 创建地理编码实例
var myGeo = new BMap.Geocoder();
geolocation.getCurrentPosition(function(r){
    if(this.getStatus() == BMAP_STATUS_SUCCESS){
        console.log('ppp')
        // console.log(r.address.city); //城市
        console.log(r.point.lat) ;//经度
        console.log(r.point.lng); //纬度
        lat=r.point.lat;
        lng=r.point.lng;

    }
});
var vm =  new Vue({
    el : "#app",
    data : {
        cont_show_:true,
        id:'',
        start:'',//入住时间
        end:'',//离店时间
        day_time:'',//入住天数
        userPhone:'15858585558',
        token:'',//id
        hotelId:'',
        longitude:'',//经度
        latitude:'',//纬度
        yesterday:'',//昨天日期
        address:'',//位置
        imgServerUrl:'',//图片地址前缀
        hotelName:'',//酒店名字
        itemLong:'',//上个页面传过来的数据集合
        city_aggre:{},//房间集合
        unitPrice:'',//单价。。接口获取的or上个页面传来的
    },
    created:function(){
        this.token = _lSGet('token');//获取公用token
        this.hotelId = _lSGet('hotelId');
        this.address = _lSGet('address');//获取上个页面传入的位置
        this.hotelName = _lSGet('hotelName');//获取上个页面传入的酒店名
        this.userPhone = _lSGet('reservePhone');//获取上个页面传入的电话
        this.longitude = +_lSGet('longitude');//获取上个页面传入的酒店经度
        this.latitude = +_lSGet('latitude');//获取上个页面传入的酒店纬度
        if( _lSGet('urls')){
            var urls =JSON.parse( _lSGet('urls'));
            this.imgServerUrl=urls.imgServerUrl+'/';
        }else{
            this.imgServerUrl=imgViewUrl;//congif里的图片路径
        };
       this.itemLong =JSON.parse( _lSGet('itemLong'));
        console.log(8899);
        console.log(this.itemLong);
        //var urls =JSON.parse( _lSGet('urls'));
        //this.imgServerUrl=urls.imgServerUrl;


    },
    mounted:function(){

        // 百度地图API功能
        var that=this;

        setTimeout(function(){
           // alert(lat);
            var map = new BMap.Map("allmap");
            map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);

            var p1 = new BMap.Point(lng,lat);//本地经纬度
            var p2 = new BMap.Point( that.longitude,that.latitude);

            console.log('9999');
            console.log(lng,lat,that.longitude,that.latitude);
            var driving = new BMap.DrivingRoute(map, {renderOptions:{map: map, autoViewport: true}});
            driving.search(p1, p2);
        },500)

    },
    methods:{





        call_phone:function(){
            window.location.href='tel:'+this.userPhone+'';
        },

    },
    computed: {

    },
    watch:{

    },

    components:{


    }


});